<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Cache-Control" content="no-siteapp">
<link rel="stylesheet" href="../../../static/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="../../../static/css/public.css" media="all" />
</head>
<body class="childrenBody">
	<form class="layui-form" lay-filter="formTest" id="form" style="width: 80%;">
		<div class="layui-form-item layui-row layui-col-xs12">
			<label class="layui-form-label">名称</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="name" lay-verify="required" placeholder="">
			</div>
		</div>

		<div class="layui-form-item layui-row layui-col-xs12">
			<label class="layui-form-label">键</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="dkey" lay-verify="required" placeholder="">
			</div>
		</div>
		<div class="layui-form-item layui-row layui-col-xs12">
			<label class="layui-form-label">值</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="dvalue" lay-verify="required" placeholder="">
			</div>
		</div>
		<div class="layui-form-item layui-row layui-col-xs12">
			<label class="layui-form-label">备注</label>
			<div class="layui-input-block">
				<textarea placeholder="" class="layui-textarea" name="remarks"></textarea>
			</div>
		</div>
		<!-- 隐藏属性 -->
		<!-- 类型 1-系统属性、2-自定义属性 -->
		<input type="hidden" name="type" value="2">
		<div class="layui-form-item layui-row layui-col-xs12">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submit">立即添加</button>
				<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="../../../static/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../../static/layui/layui.js"></script>
	<script type="text/javascript" src="../../../static/js/index.js"></script>
	<script type="text/javascript" src="../../../static/custom/js/common.js"></script>
	<script type="text/javascript">
		layui.use([ 'form', 'laydate', 'layer' ], function() {
			var form = layui.form;
			var laydate = layui.laydate;
			var layer = parent.layer === undefined ? layui.layer : top.layer, $ = layui.jquery;
			var toUpdateApi = "../../../system/dictionary/toUpdate";
			var insertApi = "../../../system/dictionary/insert";
			var updateApi = "../../../system/dictionary/update";
			var insertMethod = "post";
			var updateMethod = "put";
			var url = insertApi;
			var method = insertMethod;
			var id = getUrlParam("id");
			//判断是否编辑
			if (id) {
				url = updateApi;
				method = updateMethod;
				$("#form").append('<input type="hidden" name="id" value="" >');
				loadAjax( toUpdateApi + "/" + id, "get", null, function(response) {
					baseCallBack(response, function(response) {
						fomrVal(form, "formTest", response.data);
					});
				});
			}

			form.on("submit(submit)", function(data) {
				loadAjax( url, method, $("#form").serialize(), function(response) {
					baseCallBack(response, parentReloadCallBack);
				});
				return false;
			})
		})
	</script>
</body>
</html>